package com.ruoyi.syf.controller;

import java.util.List;

import com.ruoyi.syf.domain.RiskCheckDangerFix;
import com.ruoyi.syf.domain.vo.RiskCheckFixVo;
import com.ruoyi.syf.service.IRiskCheckDangerFixService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 隐患整改
 *
 * @author yr
 * @date 2024-08-03
 */
@RestController
@RequestMapping("/syf/fix")
public class RiskCheckDangerFixController extends BaseController {
    @Autowired
    private IRiskCheckDangerFixService riskCheckDangerFixService;

    /**
     * 查询隐患整改列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RiskCheckFixVo vo) {
        startPage();
        List<RiskCheckFixVo> list = riskCheckDangerFixService.list(vo);
        return getDataTable(list);
    }

    /**
     * 获取隐患整改详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(riskCheckDangerFixService.getInfo(id));
    }

    /**
     * 获取隐患整改基本信息
     */
    @GetMapping(value = "/basics/{id}")
    public AjaxResult getBasics(@PathVariable("id") Long id) {
        return success(riskCheckDangerFixService.getBasics(id));
    }

    /**
     * 获取隐患整改排查信息
     */
    @GetMapping(value = "/record/{id}")
    public AjaxResult getRecord(@PathVariable("id") Long id) {
        return success(riskCheckDangerFixService.getRecord(id));
    }

    /**
     * 获取隐患整改隐患信息
     */
    @GetMapping(value = "/danger/{id}")
    public AjaxResult getDanger(@PathVariable("id") Long id) {
        return success(riskCheckDangerFixService.getDanger(id));
    }

    /**
     * 整改
     */
    @Log(title = "隐患整改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult confirm(@RequestBody RiskCheckDangerFix riskCheckDangerFix) {
        return toAjax(riskCheckDangerFixService.confirm(riskCheckDangerFix));
    }

    /**
     * 删除隐患整改
     */
    @PreAuthorize("@ss.hasPermi('syf:fix:remove')")
    @Log(title = "隐患整改", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(riskCheckDangerFixService.deleteRiskCheckDangerFixByIds(ids));
    }
}
